﻿<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core_rt"%>
<%@ taglib prefix="ckeditor" uri="http://ckeditor.com" %>


<!DOCTYPE HTML>
<html>
<head>

<title>个人消息管理</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="keywords"
	content="Novus Admin Panel Responsive web template, Bootstrap Web Templates, Flat Web Templates, Android Compatible web template, 
SmartPhone Compatible web template, free WebDesigns for Nokia, Samsung, LG, SonyEricsson, Motorola web design" />
<script type="application/x-javascript"> addEventListener("load", function() { setTimeout(hideURLbar, 0); }, false); function hideURLbar(){ window.scrollTo(0,1); } </script>
<!-- Bootstrap Core CSS -->
<link href="/EMS/css/bootstrap.css" rel='stylesheet' type='text/css' />
<!-- Custom CSS -->
<link href="/EMS/css/style.css" rel='stylesheet' type='text/css' />
<!-- font CSS -->
<!-- font-awesome icons -->
<link href="/EMS/css/font-awesome.css" rel="stylesheet">
<!-- //font-awesome icons -->
<!-- js-->
<script src="/EMS/js/jquery-1.11.1.min.js"></script>
<script src="/EMS/js/modernizr.custom.js"></script>
<!--webfonts-->
<link href='/EMS/css/123.css' rel='stylesheet' type='text/css'>
<!--//webfonts-->
<!--animate-->
<link href="/EMS/css/animate.css" rel="stylesheet" type="text/css"
	media="all">
<script src="/EMS/js/wow.min.js"></script>
<script>
		 new WOW().init();
	</script>
<!--//end-animate-->
<!-- chart -->
<script src="/EMS/js/Chart.js"></script>
<!-- //chart -->
<!--Calender-->
<link rel="stylesheet" href="/EMS/css/clndr.css" type="text/css" />
<script src="/EMS/js/underscore-min.js" type="text/javascript"></script>
<script src="/EMS/js/moment-2.2.1.js" type="text/javascript"></script>
<script src="/EMS/js/clndr.js" type="text/javascript"></script>
<script src="/EMS/js/site.js" type="text/javascript"></script>
<!--End Calender-->


<!-- Metis Menu -->
<script src="/EMS/js/metisMenu.min.js"></script>
<script src="/EMS/js/custom.js"></script>
<link href="/EMS/css/custom.css" rel="stylesheet">
<!--//Metis Menu -->
</head>
<body onload="myLoad()" class="cbp-spmenu-push">

<%@include file="/header.jsp"%>


	<!-- Main content starts -->

<%@include file="/admin/adminSidebar.jsp"%>

	<div id="page-wrapper">
	 <div class="main-page">
	  <div class="tables">
		<h3 class="title1">个人消息管理</h3>
		  <form class="form-horizontal" role="form" id="frmNote"
		    action="/EMS/admin/ManageNotesServlet" method="post" >
                     
	          <input type="hidden" id="hidOperateType" name="hidOperateType" value="" />
	          <input type="hidden" id="hidNoteId" name="hidNoteId" 
	            value="${requestScope.ModifyNote.noteId}" />
	          <input type="hidden" id="hidCurrentPageIndex" name="hidCurrentPageIndex" 
              value="${currentPageIndex}" />
	          <input type="hidden" id="hidSortField" name="hidSortField" value="${sortField}" />
	          <input type="hidden" id="hidSortString" name="hidSortString" value="${sortString}" />
	          <input type="hidden" id="hidPageSize" name="hidPageSize" value="${pageSize}" />
                	    	
                	
				<div class="form-three widget-shadow " >
					<h4 class="title1">输入个人消息</h4>
					<a href="#" class="wminimize"><i class="icon-chevron-down"></i></a> 
                    <a href="#" class="wclose"><i class="icon-remove"></i></a>
                    
					<div data-example-id="form-validation-states" >
						
							<div class="form-group has-success">
								 
							<label class="control-label" for="inputSuccess1">标题</label> 
							<input type="text" class="form-control" id="txtTitle" name="txtTitle" 
                              placeholder="标题" value="${ModifyNote.title}">
                        	<span class="label label-danger" id="spanTitle"></span>

							</div>
							
							<div class="form-group has-success">
								 
							<label class="control-label" for="inputSuccess1">接收人</label> 
							<select class="form-control" id="selDepartmentId" name="selDepartmentId" onchange="selectDepartment()">
	                          <option value="0">-请选择部门-</option>
	                          <c:forEach items="${departments}" var="department">
	                          <c:if test="${empty requestScope.ModifyNote}">
	                            <option value="${department.departmentId}" 
	                              <c:if test="${ department.departmentId == selDepartmentId}">selected="selected"</c:if>>
	                            ${department.departmentName}</option>
	                          </c:if>
	                          <c:if test="${not empty requestScope.ModifyNote}">
	                            <option value="${department.departmentId}" 
	                              <c:if test="${ department.departmentId == ModifyNote.sendeeId}">selected="selected"</c:if>>
	                            ${department.departmentName}</option>
	                          </c:if>
	                          </c:forEach>
	                        </select>

							</div>
							
							<div class="form-group has-success">
								 
	                        <select class="form-control" id="selSendeeId" name="selSendeeId">
	                          <option value="0">-请选择-</option>
	                          <c:forEach items="${sendees}" var="sendee">
	                          <option value="${sendee.loginId}" 
	                            <c:if test="${sendee.loginId == ModifyNote.sendeeId}">selected="selected"</c:if>>
	                          ${sendee.loginName}</option>
	                          </c:forEach>
	                        </select>
                      
							</div>
							
							<div class="form-group has-success">
								 
							<label class="control-label" for="inputSuccess1">内容</label> 
							<textarea class="form-control" rows="3" id="txtContent" name="txtContent" 
                              placeholder="内容">${ModifyNote.content}</textarea>
                        	<ckeditor:replace replace="txtContent" basePath="/EMS/ckeditor/" />                   

							</div>

														
					<div class="form-group">
                      <div class="col-lg-offset-1 col-lg-9">
	                      <c:if test="${empty requestScope.ModifyNote}">
	                        <button class="btn btn-primary" onclick="addNote()">发布</button>                             
	                        <button type="reset" class="btn btn-default">取消</button>
	                      </c:if>
	                      <c:if test="${not empty requestScope.ModifyNote}">
	                        <button class="btn btn-primary" onclick="saveNote()">保存</button>                             
	                        <button class="btn btn-default" onclick="cancelSaveNote()">取消保存</button>
	                      </c:if>
                      </div>
                    </div>
				 </div>
				</div>
				
				<div class="form-three widget-shadow" >
					<h4 class="title1">查询个人消息</h4>

					<div data-example-id="form-validation-states">
						
						<div class="form-group has-success">
							 
						<label class="control-label" for="inputSuccess1">标题</label> 
						<input type="text" class="form-control" id="txtSearchTitle" name="txtSearchTitle" 
                          placeholder="标题" value="${searcher.title}">
                        <span class="label label-danger" id="spanSearch"></span>
						</div>
						
						<div class="form-group has-success">
							 
						<label class="control-label" for="inputSuccess1">内容</label> 
						<textarea class="form-control" rows="3" id="txtSearchContent" name="txtSearchContent" 
                          placeholder="内容">${searcher.content}</textarea>

						</div>
						
													
						<div class="form-group has-success">
							 
						<label class="control-label" for="inputSuccess1">发送时间</label> 
						<input type="text" class="form-control" id="txtSearchSendDateTimeBegin" name="txtSearchSendDateTimeBegin" 
                          placeholder="开始时间" value="${searcher.sendDateTimeBegin}"
                          class= "Wdate" onClick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss'})">
                        <input type="text" class="form-control" id="txtSearchSendDateTimeEnd" name="txtSearchSendDateTimeEnd" 
                          placeholder="结束时间" value="${searcher.sendDateTimeEnd}"
                          class= "Wdate" onClick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss'})">
                        <span class="label label-danger" id="spanSearch"></span>

						</div>
						
						<div class="form-group has-success">
							 
						<label class="control-label" for="inputSuccess1">发送人</label> 
                        <select class="form-control" id="selSenderDepartmentId" name="selSenderDepartmentId" onchange="selectDepartment()">
                          <option value="0">-请选择部门-</option>
                          <c:forEach items="${departments}" var="department">
                          <option value="${department.departmentId}" 
                            <c:if test="${department.departmentId == senderDepartmentId}">selected="selected"</c:if>>
                          ${department.departmentName}</option>
                          </c:forEach>
                        </select>
                     
						</div>
						
					  <div class="form-group has-success">
					  
                        <select class="form-control" id="selSearchSenderId" name="selSearchSenderId">
                          <option value="0">-请选择-</option>
                          <c:forEach items="${searchSenders}" var="sender">
                          <option value="${sender.loginId}" 
                            <c:if test="${sender.loginId == searcher.senderId}">selected="selected"</c:if>>
                          ${sender.loginName}</option>
                          </c:forEach>
                        </select>
                       
                         </div>
                         
                        <div class="form-group has-success">
							 
						<label class="control-label" for="inputSuccess1">接收人</label> 
                        <select class="form-control" id="selSendeeDepartmentId" name="selSendeeDepartmentId" onchange="selectDepartment()">
                          <option value="0">-请选择部门-</option>
                          <c:forEach items="${departments}" var="department">
                          <option value="${department.departmentId}" 
                            <c:if test="${department.departmentId == sendeeDepartmentId}">selected="selected"</c:if>>
                          ${department.departmentName}</option>
                          </c:forEach>
                        </select>
                     
						</div>
						
						<div class="form-group has-success">
							 
                        <select class="form-control" id="selSearchSendeeId" name="selSearchSendeeId">
                          <option value="0">-请选择-</option>
                          <c:forEach items="${searchSendees}" var="sendee">
                          <option value="${sendee.loginId}" 
                            <c:if test="${sendee.loginId == searcher.sendeeId}">selected="selected"</c:if>>
                          ${sendee.loginName}</option>
                          </c:forEach>
                        </select>
                     
						</div>
													
						
					<div class="form-group">
                    <div class="col-lg-offset-1 col-lg-9">
                     <div class="col-lg-offset-1 col-lg-9">        
                       <button class="btn btn-primary" type="reset" onclick="searchNote()">查询</button>                             
                       <button class="btn btn-default" type="reset" onclick="cancelSearchNote()">取消查询</button>              
                    </div>
                    </div>
                  </div>
			</div>
		</div>

				<div class="table-responsive bs-example widget-shadow">
					<h4>个人消息信息表</h4>
					<table class="table table-bordered">
						<thead>
							<tr>
	                          <th nowrap="nowrap" width="80px"><input type="checkbox" id="chkSelectAll" onclick="selectAll()"></input>全选</th>
	                          <th nowrap="nowrap"><a href="javascript: sorting('NoteId')">序号</a></th>
	                          <th nowrap="nowrap"><a href="javascript: sorting('Title')">标题</a></th>
	                          <th nowrap="nowrap"><a href="javascript: sorting('Senders.LoginName')">发送人</a></th>
	                          <th nowrap="nowrap"><a href="javascript: sorting('Sendees.LoginName')">接收人</a></th>
	                          <th nowrap="nowrap"><a href="javascript: sorting('SendDateTime')">发送时间</a></th>
	                          <th nowrap="nowrap"><a href="javascript: sorting('SendIp')">发送IP</a></th>
	                          <th nowrap="nowrap">操作</th>
							</tr>
						</thead>
						<tbody>
					<c:forEach items="${notes}" var="note" 
                     begin="${(currentPageIndex - 1) * pageSize}" end="${currentPageIndex * pageSize - 1}"> 
                     <tr>
                          <td nowrap="nowrap" align="center">
                            <input type="checkbox" id="chkNote${note.noteId}" name="chkNotes" value="${note.noteId}" />
                          </td>
                          <td>${note.noteId}</td>
                          <td><a href="/EMS/user/ShowNoteServlet?NoteId=${note.noteId}">${note.title}</a></td>
                          <td>${note.sender.loginName}</td>
                          <td>${note.sendee.loginName}</td>
                          <td>${note.sendDateTime}</td>
                          <td>${note.sendIp}</td>
						  <td>
							<button onclick="modifyNote(${note.noteId})">
							  <i class="glyphicon glyphicon-pencil"></i>
							</button>
							<button onclick="removeNote(${note.noteId})">
							  <i class="glyphicon glyphicon-remove"></i>
							</button></td>
                     </tr>
                     </c:forEach>
				    </tbody>
				  </table>
				  
 				<div class="widget-foot">
                    共${rowCount}条数据&nbsp;&nbsp;&nbsp;第${currentPageIndex}/${pageCount}页&nbsp;&nbsp;&nbsp;
                      <input type="radio" name="radPageSize" value="10" onclick="resize(this.value)" <c:if test="${pageSize == 10}">checked</c:if>>10条/页
                      &nbsp;&nbsp;
                      <input type="radio" name="radPageSize" value="20" onclick="resize(this.value)" <c:if test="${pageSize == 20}">checked</c:if>>20条/页
                      &nbsp;&nbsp;
                      <input type="radio" name="radPageSize" value="50" onclick="resize(this.value)" <c:if test="${pageSize == 50}">checked</c:if>>50条/页
                      <ul class="pagination pull-right">
                        <c:if test="${currentPageIndex <= 1}">
	                        <li><a>首页</a></li>
	                        <li><a>上一页</a></li>
                        </c:if>
                        <c:if test="${currentPageIndex > 1}">
	                        <li><a href="javascript: paging(1)">首页</a></li>
	                        <li><a href="javascript: paging(${currentPageIndex - 1})">上一页</a></li>
                        </c:if>
                        <c:if test="${currentPageIndex >= pageCount}">
	                        <li><a>下一页</a></li>
	                        <li><a>尾页</a></li>
                        </c:if>
                        <c:if test="${currentPageIndex < pageCount}">
                          <li><a href="javascript: paging(${currentPageIndex + 1})">下一页</a></li>
                          <li><a href="javascript: paging(${pageCount})">尾页</a></li>
                        </c:if>
                        <li><a href="javascript: removeSelect()">删除选中</a></li>
                        <li><a target="_blank" href="/EMS/admin/ExportAllNotesServlet">导出全部</a></li>
                        <li><a href="javascript: export()">导出</a></li>
                      </ul>
						<div class="clearfix"></div>
					</div>
				</div>
			</form>	
		  </div>
		</div>
	</div>


<%@include file="/footer.jsp"%>


	<!-- Scroll to top -->
	<span class="totop"><a href="#"><i class="icon-chevron-up"></i>
	</a>
	</span>

	<!--scrolling js-->
	<script src="/EMS/js/jquery.nicescroll.js"></script>
	<script src="/EMS/js/scripts.js"></script>
	<!--//scrolling js-->
	<!-- Bootstrap Core JavaScript -->
	<script src="/EMS/js/bootstrap.js"> </script>
	<script src="/EMS/js/classie.js"></script>

	<!-- Script for this page -->
	<script type="text/javascript">
var menuLeft = document.getElementById( 'cbp-spmenu-s1' ),
				showLeftPush = document.getElementById( 'showLeftPush' ),
				body = document.body;
				
			showLeftPush.onclick = function() {
				classie.toggle( this, 'active' );
				classie.toggle( body, 'cbp-spmenu-push-toright' );
				classie.toggle( menuLeft, 'cbp-spmenu-open' );
				disableOther( 'showLeftPush' );
			};
			
			function disableOther( button ) {
				if( button !== 'showLeftPush' ) {
					classie.toggle( showLeftPush, 'disabled' );
				}
			}

function checkInput() {
  var txtTitle = document.getElementById("txtTitle");
  var spanTitle = document.getElementById("spanTitle");
  
  if (txtTitle.value.length == 0) {
    spanTitle.innerHTML = "个人消息标题不能为空。";
    return false;
  }
  else {
    spanTitle.innerHTML = "";
    return true;
  }
}

function checkSearch() {
  var txtSearchTitle = document.getElementById("txtSearchTitle");
  var txtSearchContent = document.getElementById("txtSearchContent");
  var txtSearchSendDateTimeBegin = document.getElementById("txtSearchSendDateTimeBegin");
  var txtSearchSendDateTimeEnd = document.getElementById("txtSearchSendDateTimeEnd");
  var selSenderDepartmentId = document.getElementById("selSenderDepartmentId");
  var selSenderId = document.getElementById("selSenderId");
  var selSendeeDepartmentId = document.getElementById("selSendeeDepartmentId");
  var selSendeeId = document.getElementById("selSendeeId");
  var spanSearch = document.getElementById("spanSearch");
  
  if (txtSearchTitle.value.length == 0 
    && txtSearchContent.value.length == 0
    && txtSearchSendDateTimeBegin.value.length == 0
    && txtSearchSendDateTimeEnd.value.length == 0
    && selSenderDepartmentId.value.length == 0 
    && selSenderId.value.length == 0 
    && selSendeeDepartmentId.value.length == 0 
    && selSendeeId.value.length == 0 ) {
    spanSearch.innerHTML = "查询条件不能为空。";
    return false;
  }
  else {
    spanSearch.innerHTML = "";
    return true;
  }
}

function addNote() {
  if (checkInput()) {
    var frmNote = document.getElementById("frmNote");
    var hidOperateType = document.getElementById("hidOperateType");

    hidOperateType.value = "add";
    frmNote.submit();
  }
}

function removeNote(noteId) {
  if (confirm("确定要删除吗？")) {
    var frmNote = document.getElementById("frmNote");
    var hidOperateType = document.getElementById("hidOperateType");
    var hidNoteId = document.getElementById("hidNoteId");
    
    hidNoteId.value = noteId;
    hidOperateType.value = "remove";
    frmNote.submit();
  }
}

function removeSelect() {
  var count = 0;
  var chkNotes = document.getElementsByName("chkNotes");

  for (var i = 0; i < chkNotes.length; i++) {
    if (chkNotes[i].checked)
      count++;
  }
  
  if (count < 1) {
    alert ("没有选中，不能删除");
  }
  else if (confirm("确定要删除选中吗？")) {
    var frmNote = document.getElementById("frmNote");
    var hidOperateType = document.getElementById("hidOperateType");

    hidOperateType.value = "removeSelect";
    frmNote.submit();
  }
}

function modifyNote(noteId) {
  var frmNote = document.getElementById("frmNote");
  var hidOperateType = document.getElementById("hidOperateType");
  var hidNoteId = document.getElementById("hidNoteId");
  
  hidNoteId.value = noteId;
  hidOperateType.value = "modify";
  frmNote.submit();
}

function saveNote() {
  if (checkInput()) {
    var frmNote = document.getElementById("frmNote");
    var hidOperateType = document.getElementById("hidOperateType");

    hidOperateType.value = "save";
    frmNote.submit();
  }
}

function cancelSaveNote() {
  var frmNote = document.getElementById("frmNote");
  var hidOperateType = document.getElementById("hidOperateType");

  hidOperateType.value = "cancelSave";
  frmNote.submit();
}

function paging(pageIndex) {
  var frmNote = document.getElementById("frmNote");
  var hidOperateType = document.getElementById("hidOperateType");
  var hidCurrentPageIndex = document.getElementById("hidCurrentPageIndex");

  hidCurrentPageIndex.value = pageIndex;
  hidOperateType.value = "paging";
  frmNote.submit();
}

function sorting(sortField) {
  var frmNote = document.getElementById("frmNote");
  var hidOperateType = document.getElementById("hidOperateType");
  var hidSortField = document.getElementById("hidSortField");

  hidSortField.value = sortField;
  hidOperateType.value = "sorting";
  frmNote.submit();
}

function resize(pageSize) {
  var frmNote = document.getElementById("frmNote");
  var hidOperateType = document.getElementById("hidOperateType");
  var hidPageSize = document.getElementById("hidPageSize");

  hidPageSize.value = pageSize;
  hidOperateType.value = "resize";
  frmNote.submit();
} 

function searchNote() {
  if (checkSearch()) {
    var frmNote = document.getElementById("frmNote");
    var hidOperateType = document.getElementById("hidOperateType");
  
    hidOperateType.value = "search";
    frmNote.submit();
  }
}
function cancelSearchNote() {
  var frmNote = document.getElementById("frmNote");
  var hidOperateType = document.getElementById("hidOperateType");
  var txtSearchTitle = document.getElementById("txtSearchTitle");
  var txtSearchContent = document.getElementById("txtSearchContent");
  var txtSearchSendDateTimeBegin = document.getElementById("txtSearchSendDateTimeBegin");
  var txtSearchSendDateTimeEnd = document.getElementById("txtSearchSendDateTimeEnd");
  var selSenderDepartmentId = document.getElementById("selSenderDepartmentId");
  var selSenderId = document.getElementById("selSenderId");
  var selSendeeDepartmentId = document.getElementById("selSendeeDepartmentId");
  var selSendeeId = document.getElementById("selSendeeId");

  txtSearchTitle.value = "";
  txtSearchContent.value = "";
  txtSearchSendDateTimeBegin.value = "";
  txtSearchSendDateTimeEnd.value = "";
  selSenderDepartmentId.value = "";
  selSenderId.value = "";
  selSendeeDepartmentId.value = "";
  selSendeeId.value = "";
  hidOperateType.value = "calcelSearch";
  frmNote.submit();
}

function selectAll() {
  var chkSelectAll = document.getElementById("chkSelectAll");
  var chkNotes = document.getElementsByName("chkNotes");

  for (i = 0; i < chkNotes.length; i++) {
    chkNotes[i].checked = chkSelectAll.checked;
  }
}
function selectDepartment() {
  var frmNote = document.getElementById("frmNote");

  frmNote.submit();
}

function myLoad() {
  ${alertMessage}
}
/* Curve chart ends */
</script>

</body>
</html>
